home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Apple Shared Library Manager / ASLM Examples / Sample Apps / PSample / Sources / Sample.h next >
Encoding:
C/C++ Source or Header  |  1996-11-19  |  6.6 KB  |  154 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Sample.h
  3.  
  4.     Contains:    Declarations for the PSample application that are needed by Rez.
  5.  
  6.     Copyright:    © 1993-1994 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9.  
  10.  
  11. /*    These #defines correspond to values defined in the Pascal source code.
  12.     Sample.c and Sample.r include this file. */
  13.  
  14. /*    Determining an application's minimum size to request from MultiFinder depends
  15.     on many things, each of which can be unique to an application's function,
  16.     the anticipated environment, the developer's attitude of what constitutes
  17.     reasonable functionality and performance, etc. Here is a list of some things to
  18.     consider when determining the minimum size (and preferred size) for your
  19.     application. The list is pretty much in order of importance, but by no means
  20.     complete.
  21.     
  22.     1.    What is the minimum size needed to give almost 100 percent assurance
  23.         that the application won't crash because it ran out of memory? This
  24.         includes not only things that you do have direct control over such as
  25.         checking for NIL handles and pointers, but also things that some
  26.         feel are not so much under their control such as QuickDraw and the
  27.         Segment Loader.
  28.         
  29.     2.    What kind of performance can a user expect from the application when
  30.         it is running in the minimum memory configuration? Performance includes
  31.         not only speed in handling data, but also things like how many documents
  32.         can be opened, etc.
  33.         
  34.     3.    What are the typical sizes of scraps [is a boy dog] that a user might
  35.         wish to work with when lauching or switching to your application? If
  36.         the amount of memory is too small, the scrap may get lost [will have
  37.         to be shot]. This can be quite frustrating to the user.
  38.         
  39.     4.    The previous items have concentrated on topics that tend to cause an
  40.         increase in the minimum size to request from MultiFinder. On the flip
  41.         side, however, should be the consideration of what environments the
  42.         application may be running in. There may be a high probability that
  43.         many users with relatively small memory configurations will want to
  44.         avail themselves of your application. Or, many users might want to use it
  45.         while several other, possibly related/complementary applications are
  46.         running. If that is the case, it would be helpful to have a fairly
  47.         small minimum size.
  48.     
  49.     So, what did we decide on Sample? First, Sample has little risk of
  50.     running out of memory once it starts. Second, performance isn't much
  51.     of an issue since it doesn't do much and multiple windows are not
  52.     allowed. Third, there are no edit operations in Sample itself, so we
  53.     just want to provide enough space for a reasonable scrap to survive
  54.     between desk accessory launches. Lastly, Sample should intrude as little
  55.     as possible, so the effort should be towards making it as small as possible.
  56.     We looked at some heap dumps while the application was running under
  57.     various partition sizes. With a size of 23K, there was approximately
  58.     8-9K free, which is a good 'slop' factor in an application like this
  59.     which doesn't do much, but where we'd still like the scrap to survive
  60.     most of the time. */
  61.  
  62. #define kMinSize    23                /* application's minimum size (in K) */
  63.  
  64. /*    We made the preferred size bigger than the minimum size by 12K, so that
  65.     there would be even more room for the scrap, FKEYs, etc. */
  66.  
  67. #define kPrefSize    35                /* application's preferred size (in K) */
  68.  
  69. #define    rMenuBar    128                /* application's menu bar */
  70. #define    rAboutAlert    128                /* about alert */
  71. #define    rUserAlert    129                /* error user alert */
  72.  
  73. /* kSysEnvironsVersion is passed to SysEnvirons to tell it which version of the
  74.    SysEnvRec we understand. */
  75.  
  76. #define    kSysEnvironsVersion        1
  77.  
  78. /* kOSEvent is the event number of the suspend/resume and mouse-moved events sent
  79.    by MultiFinder. Once we determine that an event is an osEvent, we look at the
  80.    high byte of the message sent to determine which kind it is. To differentiate
  81.    suspend and resume events we check the resumeMask bit. */
  82.  
  83. #define    kOSEvent                app4Evt    /* event used by MultiFinder */
  84. #define    kSuspendResumeMessage    1        /* high byte of suspend/resume event message */
  85. #define    kResumeMask                1        /* bit of message field for resume vs. suspend */
  86. #define    kMouseMovedMessage        0xFA    /* high byte of mouse-moved event message */
  87. #define    kNoEvents                0        /* no events mask */
  88.  
  89. /* The following constants are used to identify menus and their items. The menu IDs
  90.    have an "m" prefix and the item numbers within each menu have an "i" prefix. */
  91.  
  92. #define    mApple                    128        /* Apple menu */
  93. #define    iAbout                    1
  94.  
  95. #define    mFile                    129        /* File menu */
  96. #define    iNew                    1
  97. #define    iClose                    4
  98. #define    iQuit                    12
  99.  
  100. #define    mEdit                    130        /* Edit menu */
  101. #define    iUndo                    1
  102. #define    iCut                    3
  103. #define    iCopy                    4
  104. #define    iPaste                    5
  105. #define    iClear                    6
  106.  
  107. /*    kTopLeft - This is for positioning the Disk Initialization dialogs. */
  108.  
  109. #define kDITop                    0x0050
  110. #define kDILeft                    0x0070
  111.  
  112. /*    kMinHeap - This is the minimum result from the following
  113.     equation:
  114.         
  115.         ORD(GetApplLimit) - ORD(ApplicationZone)
  116.         
  117.     for the application to run. It will insure that enough memory will
  118.     be around for reasonable-sized scraps, FKEYs, etc. to exist with the
  119.     application, and still give the application some 'breathing room'.
  120.     To derive this number, we ran under a MultiFinder partition that was
  121.     our requested minimum size, as given in the 'SIZE' resource. */
  122.      
  123. #define kMinHeap                21 * 1024
  124.     
  125. /*    kMinSpace - This is the minimum result from PurgeSpace, when called
  126.     at initialization time, for the application to run. This number acts
  127.     as a double-check to insure that there really is enough memory for the
  128.     application to run, including what has been taken up already by
  129.     pre-loaded resources, the scrap, code, and other sundry memory blocks. */
  130.      
  131. #define kMinSpace                8 * 1024
  132.  
  133. /* kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */
  134.  
  135. #define kExtremeNeg                -32768
  136. #define kExtremePos                32767 - 1 /* required to address an old region bug */
  137.  
  138. /* these #defines are used to set enable/disable flags of a menu */
  139.  
  140. #define AllItems    0b1111111111111111111111111111111    /* 31 flags */
  141. #define NoItems        0b0000000000000000000000000000000
  142. #define MenuItem1    0b0000000000000000000000000000001
  143. #define MenuItem2    0b0000000000000000000000000000010
  144. #define MenuItem3    0b0000000000000000000000000000100
  145. #define MenuItem4    0b0000000000000000000000000001000
  146. #define MenuItem5    0b0000000000000000000000000010000
  147. #define MenuItem6    0b0000000000000000000000000100000
  148. #define MenuItem7    0b0000000000000000000000001000000
  149. #define MenuItem8    0b0000000000000000000000010000000
  150. #define MenuItem9    0b0000000000000000000000100000000
  151. #define MenuItem10    0b0000000000000000000001000000000
  152. #define MenuItem11    0b0000000000000000000010000000000
  153. #define MenuItem12    0b0000000000000000000100000000000
  154.